Allow specific keywords to be parsed as identifiers (fix issue with RENAME COLUMN)#2203
Conversation
|
We need to rework the whole keyword management eventually. But in the meantime this can be a remedy. |
|
Hi, @manticore-projects |
|
The current implementation has grown more or less wild over 20 years and based on demand. It also suffers limitations from JavaCC 7. So my current idea was:
|
|
Hi, @manticore-projects Also, just wondering, have you ever considered adopting something like ANTLR instead, or is the plan to stick with JavaCC/CongoCC going forward? |
|
Also, when rebasing to |
|
@manticore-projects |
|
I am not doubting the strength or superiority of ANTLR in general but only point out why I was more interested in sticking with the JavaCC origin as long as possible. JavaCC/CongoCC also supports multiple languages although I am really interested in Java only (and maybe C). For my own purpose (real time parsing SQL while typing) I am interested in the fastest (automatically generated) parser possible -- and so far JavaCC holds that position. |
Summary
This PR introduces a new parser rule
KeywordOrIdentifier()to handle cases where certain keywords are used as identifiers. This addresses issues that arose after specific tokens likeNAMEwere introduced as keywords.Problem
While parsing a statement like:
the parser failed because
namewas recognized strictly as a<K_NAME>keyword after this commit, instead of being allowed as an identifier.Solution
KeywordOrIdentifier()rule that accepts:<S_IDENTIFIER><S_QUOTED_IDENTIFIER><K_NAME>,<K_NEXT>,<K_VALUE>,<K_PUBLIC>,<K_STRING>KeywordOrIdentifier().I’m open to any feedback or suggestions on this approach!